<%@ page language="java" contentType="text/html;charset=UTF-8" %><%@ include file="../../inc/global.jsp" 
%><compress:html enabled="true" removeComments="false" compressJavaScript="true" yuiJsDisableOptimizations="true">
<!doctype html>
<html>
<head>
<title>${adminGlobalConfig.name}</title>
<%@include file="../head.jsp" %>
<style type="text/css">
.pagination {margin:0px;}
input[type=text]{width:100px;}
.body .list {width:100%;}
table tr th {height:35px; line-height:35px;}
table tr td {height:30px; line-height:30px;}
.bgWithdraw{background:#e0e0e0;}
</style>
<script type="text/javascript">
$(function(){
	defaultKeys('name_', '奖品名称');
	defaultKeys('value_', '奖品价值');
	defaultKeys('cost_', '奖品成本');
	defaultKeys('count_', '奖品数量');
	$('button').click(function(){
		var btn = this;
		aju.ajaxBg(function(){
			var id = $(btn).attr('id');
			if(id == undefined) {
				id = '';
			}
			var withdraw = $('input[name=withdraw_'+ id +']:checked').val();
			var name = $('#name_'+id).val();
			var value = $('#value_'+id).val();
			var cost = $('#cost_'+id).val();
			var count = $('#count_'+id).val();
			var type = $('#type_'+id).val();
			var url = '/a/ticket/ajax/prize/save';
			$.ajax({
				url:url,
				type:'POST',
				data:{
					'id':id,
					'name':name,
					'type':type,
					'value':value,
					'cost':cost,
					'count':count,
					'withdraw':withdraw
					},
				success:function(data){
					var json = $.parseJSON(data);
					if(json.succeed) {
						window.location='/a/ticket/prize';
					} else {
						alert('保存失败' + data);
					}
				},
				error:function(){
					notif({
						msg: "操作失败！",
						type: "error",
						position:"center"
					});
				}
			});
		});
	});
});
</script>
</head>
<body>
<div class="wrapper">
<%@include file="../header.jsp" %>
<div class="body">
<div class="list">
<table>
<tr>
<th><input id="name_" name="name" type="text" value="奖品名称" style="width:260px;"/></th>
<th><input id="value_" name="value" type="text" value="奖品价值" /></th>
<th><input id="cost_" name="cost" type="text" value="奖品成本" /></th>
<th><input id="count_" name="count" type="text" value="奖品数量" style="width:60px;" /></th>
<th>
<select id="type_" name="type">
<c:forEach var="item" items="${typeItems}">
<option value="${item.type}">${item.name}</option>
</c:forEach>
</select>
</th>
<th>
<label for="withdraw_1"><input type="radio" id="withdraw_1" name="withdraw_"  value="false"/>上架</label>
<label for="withdraw_0"><input type="radio" id="withdraw_0" name="withdraw_" value="true" checked="checked"/>下架</label>
</th>
<th>
<button>添加</button>
</th>
</tr>
<c:forEach var="item" items="${prizeItems}">
<tr <c:if test="${item.withdraw}">class="bgWithdraw"</c:if>>
<td><input id="name_${item.id}" name="name" type="text" value="${item.name}" style="width:260px;"/></td>
<td><input id="value_${item.id}" name="value" type="text" value="${item.value}" /></td>
<td><input id="cost_${item.id}" name="cost" type="text" value="${item.cost}" /></td>
<td><input id="count_${item.id}" name="count" type="text" value="${item.count}" style="width:60px;" /></td>
<td>
<select id="type_${item.id}" name="type">
<c:forEach var="t" items="${typeItems}">
<option value="${t.type}" <c:if test="${item.type==t.type}">selected</c:if>>${t.name}</option>
</c:forEach>
</select>
</td>
<td>
<label for="withdraw_${item.id}_1"><input type="radio" id="withdraw_${item.id}_1" name="withdraw_${item.id}"  value="false" <c:if test="${!item.withdraw}">checked="checked"</c:if>/>上架</label>
<label for="withdraw_${item.id}_0"><input type="radio" id="withdraw_${item.id}_0" name="withdraw_${item.id}" value="true" <c:if test="${item.withdraw}">checked="checked"</c:if>/>下架</label>
</td>
<td>
<button id="${item.id}">修改</button>
</td>
</tr>
</c:forEach>
</table>
${pagination}
</div>
<!--  -->
</div>
</div>
</body>
</html>
</compress:html>